package com.boliq.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.boliq.demo.R;

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
    EditText edt1;
    EditText edt2;
    Button btn;
    Toast mtoast;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        edt1=(EditText)findViewById(R.id.edit1);
        edt2=(EditText)findViewById(R.id.edit2);
        btn=(Button)findViewById(R.id.button1);
        btn.setOnClickListener(this);
    }
    @Override
    public void onClick(View v){

        if (edt1.getText().toString().equals("")||edt2.getText().toString().equals("")) {
            Toast.makeText(LoginActivity.this,"用户名或密码不能为空",Toast.LENGTH_LONG).show();
        }else if(edt1.getText().toString().equals("123")&&edt2.getText().toString().equals("123")){
            Intent intent=new Intent(LoginActivity.this,MainActivity.class);
            startActivity(intent);
            Toast.makeText(LoginActivity.this,"登录成功",Toast.LENGTH_LONG).show();
        }else{
            Toast.makeText(LoginActivity.this,"用户名或密码错误",Toast.LENGTH_LONG).show();
        }
    }

}
